package gbench.appdemo.ggplot.aes;

import gbench.common.tree.LittleTree.IRecord;

import static gbench.common.tree.LittleTree.IRecord.*;

/**
 * 图形映射
 * 
 * @author gbench
 *
 */
public class Aesthetics {

    /**
     * 
     * @param mappings
     */
    public Aesthetics(Object... mappings) {
        this.mappings.add(REC(mappings));
    }

    /**
     * 
     * @param mappings
     */
    public static Aesthetics aes(Object... mappings) {
        return new Aesthetics(mappings);
    }

    /**
     * 提取name字段的内容
     * @param name
     * @return
     */
    public Object get(String name) {
        return mappings.get(name);
    }
    
    /**
     * 
     * @param <T>
     * @param name
     * @param defaultvalue
     * @return
     */
    public <T> T get(String name,T defaultvalue) {
        return mappings.get(name, defaultvalue);
    }
    
    /**
     * 返回映射源数据
     * @return
     */
    public IRecord getMappings() {
        return this.mappings;
    }
    
    private IRecord mappings = REC();

}
